<script>
    function dateFormat(date){
        var oldDate = new Date(date)
        var newDate = new Date()
        var diff = parseInt((newDate.getTime()-oldDate.getTime())/1000)
        console.log(diff)
        if(diff<10){
            return '刚刚'
        }else if(diff>=10 && diff<60){
            return diff + '秒前'
        } else if(diff>=60 && diff <3600){
            return parseInt(diff/60)+'分钟前'
        } else{
            return '不在计算范围内'
        }
        
    }
    console.log(dateFormat('2021-11-26 10:56:00'))
</script>